<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('公司信息')" />
	<style type="text/css">
		label.layui-form-label {width: 95px;padding-right: 0px;}
	</style>
</head>
<body class="no-skin">
<div class="main-container" id="main-container">
	<div class="main-content">
	    <div class="north">
	        <div class="north-content">
	            <form>
					<th:block th:include="listinclude :: searchTop" />
				</form>
	        </div>
	    </div>
	    <div class="mid-content">
	        <table class="layui-hide" id="dhtable" lay-filter="ftable"></table>
	    </div>
	</div>
</div>
<div id="form_d" style="padding:10px 60px 10px 10px;display:none;">
	<form class="post_form">
		<div id="dhtransfer" class="demo-transfer"></div>
	</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: motif-alone" />
<script type="text/html" id="barDh">
    <a class="layui-btn layui-btn-xs dhicon dh-edit" lay-event="edit"  shiro:hasPermission="base:company:edit">&nbsp;编辑</a>
</script>
<script th:inline="javascript">
    /*<![CDATA[*/
    var gridColumns = [[${gridColumns}]];
    var k_fields =[[${fieldRequiredList}]];
    var moduleTable=[[${moduleTable}]];
    /*]]>*/
</script>
 <script type="text/javascript">
 var $,layer,form,table,laydate,util,wherestr={};
 layui.use(['table','form','layer','jquery'], function () {
    $ = layui.$,layer = layui.layer,form = layui.form,table = layui.table,laydate = layui.laydate,util = layui.util;
	$.tablelist.init({
		elem: '#dhtable'
		,url: "/base/company/list"	
		,totalRow: gridColumns.totalRow
   		,cols: [gridColumns.gridBody
		]
		,toolbar: '#toolbar'
		,defaultToolbar: [{title:'列设置',layEvent: 'fieldSet',icon: 'layui-icon-set'}]
		,height:'full-' + ( $('.north').height()),
	});
	//头工具栏事件
	table.on('toolbar(ftable)', function(obj){
	    switch(obj.event){
	    	case 'fieldSet':
	    		filedSet(moduleTable);
         	break;
	    };
	});
	//监听工具条
    table.on('tool(ftable)', function (obj) {
        var data = obj.data;
        if (obj.event === 'edit') {
        	$.modal.open('公司信息-编辑','/base/company/edit?vId='+data.vId,$(window).width()-500, $(window).height()-200,function(index){
                var inputForm = $(window.frames["layui-layer-iframe" + index].document).contents().find(".layui-form");
                var is_return = 0,
                postStr = [],
                must_field={},
                Str = inputForm.serializeFormToJson();
	            $.each(k_fields,function (fk,fv) {
	            	var fTitle = $(window.frames["layui-layer-iframe" + index].document).contents().find("#"+fv).attr("ftitle");
                    must_field[fv] = fTitle + " 不能为空";
	            })
	            $.each(must_field,function (k,v) {
	                if(!inputForm.find("#"+k).val()){
	                    layer.msg(v);
	                    is_return = 1;
	                    inputForm.find("#"+k).css('border','1px solid red');
	                    inputForm.find("#"+k).focus()
	                    return false;
	                }
	            })
	            if(is_return)return false;
	            postStr.push(Str);
	            var data = {'infoItems':JSON.stringify(postStr)};
	            $.operate.post('/base/company/editpost',data,function(result){
	                allReload(result)
	            });
            })
        }
    });
  	//搜索按钮
 	$('#btn-search').on('click', function () {
 		$.each(wherestr,function(i,v){$("#"+i).val()?wherestr[i]=$("#"+i).val():wherestr[i]='';});//动态获取条件的值
        table.reload('dhtable', {page: {curr: 1},where:wherestr});
     });
 	//监听下拉框——添加条件
 	form.on('select(fft)', function(obj){
 		addMore(this);
 	});
    function allReload(result){
        if(result.code==0){
            setTimeout(function(){
                layer.closeAll();
                table.reload('dhtable');
            }, 1000);
        }
    }
})
 </script>
</body>
</html>